package ln.javatest.day11.demo02;

public class Demo02GenericClass{
    public static void main(String[] args) {
        //不写泛型默认为Object类型
        GenericClass gc = new GenericClass();
        gc.setName("只能是字符串");
        Object obj = gc.getName();
        System.out.println(obj); //只能是字符串

        //创建GenericClass对象，泛型使用Integer类型
        GenericClass<Integer> gc2 = new GenericClass<>();
        gc2.setName(12);
        int a  = gc2.getName(); //自动拆箱
        Integer a1 = gc2.getName();
        System.out.println(a); //12
        System.out.println(a1); //12
    }
}
